package com.project.chat.pojo;

import lombok.Data;

import java.util.Date;

@Data
public class Message {
    //消息类型 1.普通消息 2.公告消息
    private String type;
    //时间
    private String time;
    //接收方
    private String to;
    //发送方
    private String from;
    //消息
    private String msg;

    public Message(){}

    public Message(String type, String time, String to, String from, String msg){
        this.type = type;
        this.time = time;
        this.from = from;
        this.to = to;
        this.msg = msg;
    }

    public Message(String type, String time, String from, String msg){
        this(type, time, "", from, msg);
    }

    public Message(String type, String from, String msg){
        this(type, new Date().toLocaleString(), from, msg);
    }

    public void setMsg(String type, String time, String to, String from, String msg){
        this.type = type;
        this.time = time;
        this.from = from;
        this.to = to;
        this.msg = msg;
    }

    public void setMsg(String type, String time, String from, String msg){
        this.setMsg(type, time, "", from, msg);
    }

    public void setMsg(String type, String from, String msg){
        this.setMsg(type, new Date().toLocaleString(), from, msg);
    }

    public void setMsg(String type, String msg){
        this.setMsg(type, "", msg);
    }

}
